import java.io.*;
import java.util.*;

public class XMLopener {
    public static void main(String[] args) {
        FileInputStream fis = null;
        InputStreamReader isr = null;
        BufferedReader br = null;
        // FileWriter fStream = null;
        // BufferedWriter bWriter = null;
        
        // StringBuffer sb = new StringBuffer();
        String textinLine = " ";
        
        try {
            fis = new FileInputStream("routes.txt");
            isr = new InputStreamReader(fis);
            br = new BufferedReader(isr);
            // fStream = new FileWriter("galapunkti.txt");
            // bWriter = new BufferedWriter(fStream);
            
            textinLine = br.readLine();
            String [] textElements;
            List<String> routeRSID = new ArrayList<String>();
            List<String> routeNum = new ArrayList<String>();
            List<String> routeDestination = new ArrayList<String>();
            List<String> routeDestinationBack = new ArrayList<String>();
            int i = 0;
            // String smTemp = " ";
            
            // String [] smTempElement;
            while((textinLine = br.readLine()) != null) {
                textElements = textinLine.split("\\,");
                for(String temp : textElements) {
                    if(temp.contains("_bus_") || temp.contains("_nightbus_"))
                        routeRSID.add("autobuss");
                    else if(temp.contains("_tram_"))
                        routeRSID.add("tramvajs");
                    else if(temp.contains("_trol_"))
                        routeRSID.add("trolejbuss");
                    else if(temp == textElements[1])
                        routeNum.add(temp);
                    else if(temp == textElements[2])
                        routeDestination.add(temp);
                    else if(temp == textElements[3])
                        routeDestinationBack.add(temp);
                }
                
                do {
                    System.out.println(routeRSID.get(i) + "\t"
                            + routeNum.get(i) + "\t"
                            + routeDestination.get(i) + "\t"
                            + routeDestinationBack.get(i));
                    i++;
                }while(i < routeRSID.size());
                /* smTemp = textElements[2];
                smTempElement = smTemp.split("\\,,");
                
                for(String utemp : smTempElement) {
                    if(utemp == smTempElement[0])
                        stopGPSlatitude.add(utemp);
                }
                sb.append(stopIDList.get(i) + " " + stopTitle.get(i)
                        + " " + stopGPSlatitude.get(i) + "\n");
                bWriter.write(sb.toString());
                ++i;
                sb.delete(0, sb.length()); */
            }
            // bWriter.close();
        }catch(IOException e) {
            e.printStackTrace();
        }
    }
}